<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {

    protected function _initDoctype() {
        $this->bootstrap('view');
        $view = $this->getResource('view');
        $view->doctype('XHTML1_STRICT');
    }

    /**
     * Inititalise la vue pour tout les actions
     * @return Zend_View
     */
    protected function _initView() {
        // Initialize view
        $view = new Zend_View();
        $view->doctype('XHTML1_STRICT');
        $view->setEncoding('UTF-8');
        $view->headTitle('XML Project');

//        Zend_Debug::dump(get_class_methods($view));
        //Obtenir dans quel environnement qu'on travail
        $view->env = APPLICATION_ENV;

        // Ajout de ViewRenderer
        $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
        $viewRenderer->setView($view);

        return $view;
    }

    protected function _initSession() {
        $options = $this->getOptions();
        $session = new Zend_Session_Namespace($options['resources']['session']['namespace']);
        Zend_Registry::set('session', $session);
    }

    /**
     * Initialize application autoloader
     *
     * @return void
     */
    protected function _initAppAutoload() {

        $moduleLoader = new Zend_Application_Module_Autoloader(array(
                    'namespace' => '',
                    'basePath' => APPLICATION_PATH));

        $autoloader = Zend_Loader_Autoloader::getInstance();
        $autoloader->suppressNotFoundWarnings(false);
        $autoloader->setFallbackAutoloader(true);
        return $autoloader;
    }

    /**
     * Initialise les plugins
     */
//    protected function _initPlugins() {
//        // Access plugin
//        $front = Zend_Controller_Front::getInstance();
//        $front->registerPlugin(new Plugin_Layout());
//    }

    /**
     * Test Router page Home
     */
    protected function _initRouter() {
        $front = $this->bootstrap('FrontController')->getResource('FrontController');
        $router = $front->getRouter();
//        $route = new Zend_Controller_Router_Route('accueil', array('controller' => 'index', 'action' => 'index'));
//        $router->addRoute('accueil', $route);
        //Fichier config
        $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/route.ini', 'production');
        $routing = new Zend_Controller_Router_Rewrite();
        $routing->addConfig($config, 'routes');
        $front->setRouter($routing);

    }

}

